<%-- 
    Document   : fetchPassword
    Created on : 2008-9-2, 16:08:01
    Author     : Ruby
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page import="sunsite.tools.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>密码找回</title>
        <%  String serverPath = Path.getServerUrl(request); %>
        <link rel="stylesheet" type="text/css" href="<%=serverPath%>ExtJs/resources/css/ext-all.css" />
        <script type="text/javascript" src="<%=serverPath%>ExtJs/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="<%=serverPath%>ExtJs/ext-all.js"></script>
        <script type="text/javascript" src="<%=serverPath%>js/user.js"></script>
        <script type="text/javascript" src="<%=serverPath%>js/tools.js"></script>
    </head>
    <body>
    <script>
        var userNameParam = null;
        var emailParam = null;
        var verifyCodeParam = null;
        function fetchPassword(userName,email,verifyCode)
        {
            var conn = new Ext.data.Connection();
              // 发送异步请求
            conn.request({
              // 请求地址
                url: 'fetchPsw.action',
                method: 'GET',
                params:'userName='+userName+'&email='+email+'&verifyCode='+verifyCode,
                // 指定回调函数
                callback: callback
            });
            //回调函数
            function callback(options, success, response){
                if(success){
                  // 如果成功则使用Ext将JSON字符串转换为JavaScript对象
                    var jsonObj = Ext.util.JSON.decode(response.responseText);
                    if(jsonObj.answer == 1)
                    {
                        Ext.Msg.alert(jsonObj.title,jsonObj.msg);
                    }
                    else
                    {
                        TipMessageShow(jsonObj.title, jsonObj.msg,divMessageTipFetch,'divMessageTipFetch');
                    }
                    //document.getElementById('textId').innerHTML = jsonObj.msg;
                }
                else
                {
                    Ext.Msg.alert('错误提示','连接服务器失败');
                }
            }
        }
    </script>
      <s:form action="fetchPsw" method="GET">
                <table>
                  <tr>
                    <td align="left"><s:text name="user.userName"/></td>
                    <td colspan="2"><input onchange="userNameParam = this.value" name="userName" type="text" maxlength="20" size="30"/></td>
                  </tr>
                  <tr>
                    <td align="left"><s:text name="user.email"/></td>
                    <td colspan="2"><input name="email" onchange="emailParam = this.value" type="text" maxlength="40" size="30"/></td>
                  </tr>
                  <tr>
                        <td align="right" valign="center"><font size="2" ><s:text name="message.verifyCode"/></font></td>
                        <td align="left" valign="center">
                            <table cellpadding="0px" cellspacing="0px">
                                <tr>
                                    <td width="80px" valign="center"><input name="verifyCode" onchange="verifyCodeParam = this.value" type="text" class="textbox" maxlength="6" size="6"></td>
                                    <td valign="center"><img id="verifyCodeImageRegister" src='<%=serverPath%>tools/verifyCode.jsp?width=80&heigth=24'/></td>
                                </tr>
                            </table>
                        <td valign="center" align="left"><a href="#" onclick='return getVerifyCode("verifyCodeImageRegister","<%=serverPath%>");'><font size="2" > <s:text name="message.refreshCode"/></font></a></td>
                    </tr>
                  <tr>
                    <td colspan="3">
                      <input type="button" onclick="return fetchPassword(userNameParam,emailParam,verifyCodeParam);" value="确定">
                    </td>
                  </tr>
                </table>
      </s:form>

<!--用于输出消息-->
<div id="divMessageTipFetch"></div>
    </body>
</html>
